package org.jsbd.boss.dao.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.jsbd.boss.common.DataGridModel;
import org.jsbd.boss.dao.ICommentDao;
import org.jsbd.boss.domian.Comment;

public class CommentDaoImpl extends CrackBaseDao implements ICommentDao {

	@Override
	public void save(Comment comment) {
		super.insert("qy_comment.insert_comment", comment);
	}
	
	@Override
	public void save(List<Comment> list) {
		super.batchInsert("qy_comment.insert_comment", list);
	}

	@Override
	public void update(Comment comment) {
		super.insert("qy_comment.update_comment", comment);
	}
	
	@Override
	public void updateUsed(Comment comment) {
		super.insert("qy_comment.update_comment_used", comment);
	}

//	@Override
//	public Comment get(Comment comment) {
//		return (Comment) super.queryForObject("qy_comment.select_comment_one", comment);
//	}
	
	@Override
	public Comment getByMark(String mark) {
		return (Comment) super.queryForObject("qy_comment.select_comment_by_mark", mark);
	}
	
	@Override
	public Comment getById(Integer id) {
		return (Comment) super.queryForObject("qy_comment.select_by_id", id);
	}

	@SuppressWarnings("unchecked")
	@Override
	public List<Comment> getList(Comment comment) {
		return super.queryForList("qy_comment.select_comment_list", comment);
	}

	@Override
	public Map<String, Object> getListPage(DataGridModel page, Comment form) {
		form = (form == null ? new Comment() : form);
		form.setPageInfo(page);
		Map<String, Object> results = new HashMap<String, Object>();
		results.put("total", super.queryForCount("qy_comment.select_comment_page_count_new", form));
		results.put("rows", super.queryForList("qy_comment.select_comment_list_new", form));
		return results;
	}
	
	@Override
	public void delete(List<Integer> ids) {
		super.batchUpdate("qy_comment.delete_comment", ids);
	}

	@Override
	public void updateUsedByMark(String mark) {
		super.insert("qy_comment.update_comment_used_by_mark", mark);
	}

}
